package com.sendmail;


import org.springframework.mail.SimpleMailMessage;
import org.springframework.mail.javamail.JavaMailSenderImpl;

import java.util.Properties;

/**
 * Created by lilima on 2015/10/13.
 */
public class SingleMailSend {
    public JavaMailSenderImpl senderImpl;

    public SingleMailSend(){
        senderImpl = new JavaMailSenderImpl();
        senderImpl.setHost("smtp.sina.com");
        senderImpl.setUsername("malili_test@sina.com");
        senderImpl.setPassword("maliliTest");
    }
    public static void main(String args[])
    {
        SingleMailSend singleMailSend = new SingleMailSend();
        //
        SimpleMailMessage
                mailMessage = new SimpleMailMessage();
        mailMessage.setTo("lilima@Ctrip.com");
        mailMessage.setFrom(singleMailSend.senderImpl.getUsername());
        mailMessage.setSubject("Hello Title");
        mailMessage.setText(" Hello Content ");



        Properties prop = new Properties();
        prop.put("mail.smtp.auth", "true"); //
        prop.put("mail.smtp.timeout", "25000");
        singleMailSend.senderImpl.setJavaMailProperties(prop);
        // sendmail
        singleMailSend.senderImpl.send(mailMessage);

        System.out.println(" Send OK.. ");
    }
}